package com.nuaa.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.nuaa.dao.base.impl.BaseDaoImpl;
import com.nuaa.dao.inter.CustomDaoInter;
import com.nuaa.domain.user.customer.CustomerInfo;

/**
 * 用户Dao
 * @author sevn
 *
 */
@Repository("customDao")
public class CustomDaoImpl extends BaseDaoImpl<CustomerInfo, Integer> implements CustomDaoInter{
	
	public void add(CustomerInfo custom) {		
		this.save(custom);
	}
	

	@Override
	public List<String> getAllLoginName() {
		String sql = "select login_name from customer_info";
		List<String> loginNameList= getJdbcTemplate().queryForList(sql, String.class);
		return loginNameList;
	}
	
	public void updateInfo(CustomerInfo custom) throws Exception{
		super.update(custom);
	}

	@Override
	public List<CustomerInfo> getAll() {
		String sql = "select * from customer_info";
		return super.search(CustomerInfo.class, sql);
	}

	@Override
	public List<CustomerInfo> getAllByPage(int firstindex,int maxresult,String critiria) {
		String sql = "select * from customer_info"+critiria+"order by customerNo desc";
		return super.search(CustomerInfo.class, sql, firstindex, maxresult);
	}

	@Override
	public long getCount() {
		String sql = "select * from customer_info";
		return super.count(sql);
	}

	@Override
	public void delete(Integer[] ids) {
		super.delete(CustomerInfo.class, ids);
	}

	@Override
	public long getCount(String critiria) {
		String sql = "select * from customer_info"+critiria;
		return super.count(sql);
	}
	
}
